package com.yiqi.zhiyuan.feature.mine.view;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.widget.TextView;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;
import com.suozhang.framework.utils.AppUtil;
import com.yiqi.zhiyuan.R;
import com.yiqi.zhiyuan.entity.vo.TextVO;
import com.yiqi.zhiyuan.framework.api.UserApi;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @ProjectName: ZhiYuan
 * @Package: com.yiqi.zhiyuan.feature.mine.view
 * @ClassName: ActivityAbout
 * @Description: java类作用描述
 * @Author:
 * @CreateDate: 2019/3/12 17:15
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/12 17:15
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class ActivityAbout extends BaseActivity {
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.tv_app_version)
    TextView mTvAppVersion;
    @BindView(R.id.tv_about)
    TextView tvAbout;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_about;
    }

    @Override
    protected void initView() {
        super.initView();
        initToolBar(mToolbar, getString(R.string.about_title), true, true);
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initData() {
        String version = String.format("版本号V%s", AppUtil.getVersionName(this));
        mTvAppVersion.setText(version);

        AM.api().createApiService(UserApi.class)
                .selectAboutUs()
                .compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer())
                .subscribe(new Observer<TextVO>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(TextVO textVO) {
                        tvAbout.setText(Html.fromHtml(textVO.getContent()));

                    }

                    @Override
                    public void onError(Throwable e) {
                        showMsg(e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });


    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
